<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Bannerwarring_model extends Model
{
	private $_host;
	private $_dbname;
	private $_username;
	private $_password;
	private $_port;

	function Bannerwarring_model()
	{
		parent::Model();
		
		$host = $this->db->hostname;
		$arrHost = explode(':',$host);
		
		$this->_host = trim($arrHost[0]);
		$this->_dbname = $this->db->database;
		$this->_username = $this->db->username;
		$this->_password = $this->db->password;
		$this->_port = $this->db->port;
	}
	
	function getAll()
	{
		$data = array();
		$iconn = mysqli_connect($this->_host, $this->_username, $this->_password, $this->_dbname, $this->_port);
		$result = mysqli_query($iconn, "CALL selfserving_get_lstbanner_warning();") or die(mysqli_error($iconn));
        while($row = mysqli_fetch_object($result))
        {
			$data[] = $row;
		}

		mysqli_free_result($result);
		mysqli_close($iconn);
		return $data;
	}
	
	function saveWarring($id, $text)
	{
		$iconn = mysqli_connect($this->_host, $this->_username, $this->_password, $this->_dbname, $this->_port);
		mysqli_query($iconn, "CALL selfserving_banner_update_description($id,'$text');") or die(mysqli_error($iconn));

		mysqli_close($iconn);
	}
}